precision mediump float;

varying vec3 v_color;
varying vec4 v_clipPos4;

uniform sampler2D u_sampler0;

void main() {

    // 判断片元是否在阴影中
    vec3 shadowCoord = (v_clipPos4.xyz/v_clipPos4.w) / 2.0 + 0.5;
    vec4 depthInfo = texture2D(u_sampler0,shadowCoord.xy);
    float factor = 1.0;
    if(shadowCoord.z > depthInfo.r + 0.005){
        // 在阴影中
        factor = 0.5;
    }

    gl_FragColor = vec4(factor * v_color,1.0);
}
